import { defineConfig,loadEnv } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import vueJsx from '@vitejs/plugin-vue-jsx';
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {

  const env = loadEnv(mode, process.cwd(), '')
  return {
    base: './',
    resolve: {
      alias: {
        '@': '/src',
      },
    },
    server: {
      host: true,
      open: false,
      port: 5173,
      cors: true,
      proxy: {
        '/api': {
          target: env.VITE_BASE_URL,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ''),
        },
      },
    },
    plugins: [uni(), vueJsx({})],
  };
})
